<template>
	<view class="content container">
		<view class="tabBox">
			<view @tap="reload('2')" :class="showType == '2' ? 'tab act' : 'tab'">
				<text>按价格排序</text>
				<view class="line"></view>
			</view>
			<view @tap="reload('1')" :class="showType == '1' ? 'tab act' : 'tab'">
				<text>按编号排序</text>
				<view class="line"></view>
			</view>
		</view>

		<view class="listBox">
			<view class="listItem" v-for="(item, index) in goodsList" :key="index">
				<view class="goodsList"  @click="go(`secondGoodsDetail?id=${item.id}&order_type=2`)">
					<!-- <image class="goodImg" :src="domain + item.goods_cover_image" mode=""></image> -->
					<view class="msgBox">
						<!-- <view class="goodName">{{item.product.name}}
							<text class="maanghe_status" v-if="item.goods_type == 1">盲盒</text>
						</view> -->
						<view class="flex_bt">
							<view class="price">{{item.price}}元</view>
							<view class="time">{{item.product.name}}</view>
						</view>
						<view class="flex_bt">
							<view class="collection_code">{{item.user_collection.collection_code}}
							<text class="maanghe_status" v-if="item.pay_text == 0">寄售</text>
							<text class="maanghe_status suodan" v-if="item.pay_text == 1">锁单中</text>
							</view>
							<view class="time">认证标识：{{item.id}}</view>
						</view>
					</view>
				</view>


			</view>
		</view>
		<uni-load-more :status="status" v-if="goodsList.length"></uni-load-more>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				domain: 'http://xingfeng.art',
				goodType: 1,
				goods_id: 0,
				showType: '2',
				goodsList: [],
				status: 'more',
				pagesize: 10,
				page: 1,
				flag: false, //上拉加载
			}
		},
		onShow() {
			this.Reset();
		},
		onLoad(e) {
			this.goodType = e.type
			this.goods_id = e.goods_id
		},
		onReachBottom() {
			if (!this.flag) {
				console.log(1)
				this.status = "loading";
				this.page++;
				this.getList()
			}
		},
		onPullDownRefresh() {
			this.Reset();
		},
		methods: {
			Reset() {
				this.flag = false;
				this.page = 1;
				this.goodsList = [];
				this.getList(this.showType)
			},
			reload(n) {
				if (this.showType != n) {
					this.showType = n;
					this.Reset();
				}
			},
			greload(n) {
				if (this.goodType != n) {
					this.goodType = n;
					this.Reset();
				}
			},
			//跳转到盲盒详情界面
			gotoMangheDetail(item){
				console.log('1212122')
				this.go('secondGoodsDetail?goodsId=' + item.goods_id)
			},
			getList() {
				let data = {
					goods_id: this.goods_id,
					goods_type: this.goodType,
					page: this.page,
					price: this.showType
				}

				this.$http.post('market/market/marketList', data).then(res => {
					uni.stopPullDownRefresh();
					if (res.code == 1) {
						if (res.data.data.length == 0) {
							this.flag = true;
							this.status = 'noMore'
						} else {
							this.goodsList = this.goodsList.concat(res.data.data);
							if (res.data.data.length < this.pagesize) {
								this.flag = true;
								this.status = 'noMore'
							}
						}
					} else {
						this.flag = true;
						this.status = 'noMore'
					}
				})
			},
		}
	}
</script>
<style lang="scss" scoped>
	.content {
		padding-bottom: 120rpx;

		.specs_boxs {
			padding: 50rpx 0 10rpx;
			width: 600rpx;
			background: #FFFFFF;
			border-radius: 12rpx;
			margin: 0 auto;

			.ipt {
				flex: 1;
				height: 100rpx;
				line-height: 100rpx;
				font-size: 28rpx;
				font-weight: 500;
				font-family: PingFangSC-Medium;
				color: #333;
				background-color: #F8F8F8;
				padding-left: 30rpx;
				margin: 0 30rpx;

			}

			.iptP {
				color: #777777;
				font-weight: 400;
				font-family: PingFangSC-Regular;
			}

			.btnBox {
				margin-top: 20rpx;

				.btn {
					flex: 1;
					height: 80rpx;
					line-height: 80rpx;
					text-align: center;
					font-size: 30rpx;
					font-family: PingFangSC-Medium;
				}

				.btn1 {
					color: #4BB746;
				}
			}
		}

		.tabBox {
			width: 100%;
			height: 100rpx;
			background-color: #FFFFFF;
			display: flex;
			position: fixed;
			top: var(--window-top);
			left: 0;
			z-index: 12;
			justify-content: space-evenly;

			.tab {
				width: 25%;
				position: relative;
				font-size: 26rpx;
				color: #000000;
				height: 90rpx;
				line-height: 90rpx;
				text-align: center;
				.line {
					position: absolute;
					left: calc(50% - 25rpx);
					bottom: 0rpx;
					width: 40rpx;
					height: 16rpx;
					background-image:url(../../static/img/line.png) ;
					background-repeat: no-repeat;
					background-size: 40rpx 16rpx;
					display: none;
				}

				&.act {
					font-size:26rpx;
					font-weight: 600;
					color: #000000;
					.line {
						display: block;
					}
				}
			}
		}

		.toptabBox{
			margin-top: 0px;
			justify-content: center;
			height: 35px;
			padding-top: 10px;
			padding-bottom: 10px;
			.tab {
				    background: #fff;
				    color: #000;
					border: 1px solid #fff;
				    height: 30px;
				    line-height: 30px;
				}
			.act{
				border: 1px solid #817e7e;

			}
		}
		.listBox {
			padding: 120rpx 30rpx 0;

			.listItem {
				// background: #383B3F;
				border-radius: 10rpx;
				margin-bottom: 30rpx;
				padding: 0 30rpx;
				border: 1px solid #efefef;

				.listType {
					font-size: 26rpx;
					font-weight: 500;
					height: 88rpx;
					line-height: 88rpx;
					border-bottom: 2rpx solid #383B3F;
					.shopIcon {
						width: 32rpx;
						height: 32rpx;
						margin-right: 10rpx;
					}
					.orderNumber {
						flex: 1;
						color: #000;
						font-weight: bold;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
					.state1{
						color: #00DB7D;
					}
					.state {
						color: #AAAAAA;
					}
				}

				.goodsList {
					padding: 30rpx 0;
					display: flex;
					.goodImg {
						width: 180rpx;
						height: 180rpx;
						margin-right: 20rpx;
					}
					.msgBox {
						flex: 1;
						.goodName {
							font-size: 28rpx;
							font-weight: 400;
							color: #000000;
							line-height: 40rpx;
							margin-bottom: 20rpx;
							display: -webkit-box;
							-webkit-box-orient: vertical;
							-webkit-line-clamp: 2;
							overflow: hidden;
						}
						.maanghe_status{
							background-color: #00E072;

							border-radius: 16rpx;
							color: #333333;
							line-height: 32rpx;
							font-size: 24rpx;
							color: #FFFFFF;
							text-align: center;
							font-weight: bold;
							padding: 2px 10px;
							display: inline-block;
							margin-left: 20rpx;
						}

						.suodan{
							background-color: rgb(229, 229, 229);
							color: rgb(102, 102, 102);
						}

						.price {
							font-size: 32rpx;
							font-weight: 500;
							color: #000000;

						}
						.collection_code{
							font-size: 28rpx;
							color: #AAAAAA;
						}
						.time {
							color: #AAAAAA;
							font-size: 24rpx;
							text-align: right;
						}
					}
				}


				.handBox {
					height: 108rpx;
					font-size: 28rpx;
					display: flex;
					justify-content: flex-end;
					align-items: center;
					border-top: 2rpx solid #666262;

					.Btn {
						width: 140rpx;
						height: 56rpx;
						line-height: 56rpx;
						text-align: center;
						border-radius: 28rpx;
						font-weight: 500;
						font-family: PingFangSC-Medium;
						font-size: 28rpx;
						border: 2rpx solid #777777;
						color: #777777;
						margin-left: 20rpx;
					}

					.payBtn {
						border: 2rpx solid #4BAE45;
						color: #4BAE45;
					}

				}
			}
		}

		/* 密码弹框 */
		.iptPopBox {
			position: fixed;
			width: 100%;
			height: 100%;
			left: 0;
			top: 0;
			background: rgba(0, 0, 0, .8);

			.iptInner {
				width: 657rpx;
				margin: 400rpx auto;
				background: #0B0337;
				border-radius: 20rpx;

				.iptTit {
					height: 98rpx;
					line-height: 98rpx;
					text-align: center;
					color: #A59BDD;
					font-size: 32rpx;
					border-bottom: 2rpx solid #02000A;
				}

				.showmsg {
					color: #A59BDD;
					font-size: 30rpx;
					line-height: 60rpx;
					padding: 40rpx;
					border-bottom: 2rpx solid #02000A;
				}

				.msg {
					padding: 40rpx;
					line-height: 83rpx;
					color: #A59BDD;
					font-size: 30rpx;
					text-align: center;
					border-bottom: 2rpx solid #02000A;
				}

				.iptWarp {
					width: 100%;
					border-bottom: 2rpx solid #02000A;

					.iptBoxInupt {
						width: 604rpx;
						height: 83rpx;
						font-size: 30rpx;
						line-height: 83rpx;
						text-indent: 20rpx;
						color: #A59BDD;
						background: #02000A;
						margin: 40rpx auto;
					}

					.iptBoxIptColor {
						color: #62647A;
					}
				}

				.iptBtns {
					display: flex;

					.iptBoxBtn {
						flex: 1;
						text-align: center;
						height: 98rpx;
						line-height: 98rpx;
						color: #A59BDD;
						font-size: 32rpx;
					}

					.iptBoxBtn:nth-of-type(1) {
						border-right: 2rpx solid #02000A;
					}

					.iptBoxBtn:nth-of-type(2) {
						border-left: 2rpx solid #02000A;
					}
				}
			}
		}
	}

	.pop_box {
		width: 100%;
		padding: 30rpx 0 100rpx;
		color: #333333;
		background-color: #FFFFFF;

		.item {
			margin: 20rpx 30rpx;
			display: block;
			box-shadow: 0px 0px 9rpx 1rpx rgba(61, 61, 61, 0.1);
			border-radius: 20rpx;
			background-color: #FFFFFF;
			margin-bottom: 30rpx;
			height: 80rpx;
			padding: 20rpx 30rpx;
			display: flex;
			align-items: center;

			image {
				width: 50rpx;
				height: 50rpx;
				margin-right: 20rpx;
			}

			text {
				flex: 1;
				font-size: 30rpx;
				font-weight: 500;
				color: #333333;
			}
		}

		.btns {
			display: flex;
			justify-content: space-around;
			padding-bottom: 10px;

			button {
				width: 260rpx;
				height: 71rpx;
				line-height: 70rpx;
				color: #FFFFFF;
				background: rgba(246, 177, 58, 1);
				border-radius: 35rpx;
			}

			.last {
				background-color: #52BBB6;
			}
		}
	}
</style>
